package com.tfswx.jkgl.core.yzfs;

import com.tfswx.jkgl.core.yzfs.base.YzfsBase;
import org.springframework.stereotype.Component;

/**
 * @author ricky
 * @date 2021/12/6
 */
@Component
public class ValueRange implements YzfsBase {
    @Override
    public boolean isValid(Object value, Object yzz) {
        if (value == null) {
            return true;
        }

        String vStr = value.toString();
        for (String item : String.valueOf(yzz).split(",")) {
            if (vStr.equals(item)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String getName() {
        return "包含于";
    }

    @Override
    public boolean sfxycs() {
        return true;
    }

    @Override
    public String getMessage() {
        return "值不正确";
    }

    @Override
    public String getYzzValue(String yzz) {
        return "{\"" + String.join("\", \"", yzz.split(",")) + "\"}";
    }
}
